import { UseConnectWalletExample } from '../../../examples/wallet-hooks';

# useConnectWallet

The `useConnectWallet` hook is a mutation hook for establishing a connection to a specific wallet.

```ts
import { ConnectButton, useConnectWallet, useWallets } from '@mysten/dapp-kit';

function MyComponent() {
	const wallets = useWallets();
	const { mutate: connect } = useConnectWallet();

	return (
		<div style={{ padding: 20 }}>
			<ConnectButton />
			<ul>
				{wallets.map((wallet) => (
					<li key={wallet.name}>
						<button
							onClick={() => {
								connect(
									{ wallet },
									{
										onSuccess: () => console.log('connected'),
									},
								);
							}}
						>
							Connect to {wallet.name}
						</button>
					</li>
				))}
			</ul>
		</div>
	);
}
```

## Example

<UseConnectWalletExample />

## Connect arguments

- `args` - Arguments passed to the `connect` function of the wallet.

  - `wallet` - The wallet to connect to.
  - `accountAddress` - (optional) The address in the wallet to connect to.

- `options` - Options passed the `useMutation` hook from
  [@tanstack/react-query](https://tanstack.com/query/latest/docs/react/guides/mutations).
